#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool compare(string& a, string& b) {
    return a + b > b + a;
}
int main() {
    int n;
    cin >> n;
    vector<string> v;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end(), compare);
    for(auto& s : v) {
        cout << s;
    }
    return 0;
}